/******* Plugin JS ********/

//选项相关
//=============================================================
//社交活动 - 感兴趣
function aj_add_social(dataid, userid, typeid)
{
	$.ajax({
		type:"POST",
		url:"/ajax/add_social/",
		data:"dataid="+dataid+"&userid="+userid+"&typeid="+typeid,
		success:function(data){
			if(data > 0) {
				$("#socialmsg"+typeid).html(data);
			}  else {
				alert("请不要重复操作");
			}
		}
	});
}

//专题 - 观点
function aj_add_special(dataid, userid, typeid)
{
	$.ajax({
		type:"POST",
		url:"/ajax/add_special/",
		data:"dataid="+dataid+"&userid="+userid+"&typeid="+typeid,
		success:function(data){
			if(data > 0) {
				$("#specialmsg"+typeid).html(data);
			}  else {
				alert("请不要重复操作");
			}
		}
	});
}

//JS热点表单相关
//=============================================================
function preview_addhot_form(preurl) {
	//验证
	var empty_title = empty_posid = false;
	//验证字段
	empty_title = check_empty_field2($("#title"), "title", "标题");
	empty_posid = check_empty_field2($("#posid"), "posid", "发表位置");
	if(empty_title || empty_posid) {
		return false;	
	}
//	alert($("#description").val());return;
	//提交预览
	$("#hotform").attr("action", preurl);
	$("#hotform").submit();	
}

//预览话题
function preview_forumform_form(preurl) {
	//验证
	var empty_title = false;
	//验证字段
	empty_title = check_empty_field2($("#title"), "title", "标题");
	if(empty_title) {
		return false;	
	}
	//提交预览
	$("#forumform").attr("action", preurl);
	$("#forumform").submit();	
}

//热点图片切换
function show_hot_pic(obj, pic){
	$("#hotlist > li").removeClass('sel');
	$("#"+obj).addClass('sel');
	$("#hotpic").attr('src', pic);
}

//JS验证表单相关
//=============================================================
//检测发布热点表单
function check_addhot_form(form) {
	var empty_title = empty_posid = false;
	//验证字段
	empty_title = check_empty_field(form.title, "title", "标题");
	empty_posid = check_empty_field(form.posid, "posid", "发表位置");
	
	if(empty_title || empty_posid) {
		return false;	
	}	
}

//检测发布话题表单
function check_forumform_form(form) {
	var empty_title = false;
	//验证字段
	empty_title = check_empty_field(form.title, "title", "标题");
	if(empty_title) {
		return false;	
	}	
}

//检测发布广播表单
function check_miniblogform_form(form) {
	var empty_description = false;
	//验证字段
	empty_description = check_empty_field(form.description, "description", "广播内容");
	if(empty_description) {
		return false;	
	}	
}


//显示非空错误提示
function check_empty_field(textfield, field, msg) {
	var obj = $("#"+field+"_msg");
	if(textfield.value == "") {
		obj.html(msg+"不能为空");	
		obj.show();
		return true;
	} else {
		obj.html("");	
		obj.hide();
	}
	return false;
}

//显示非空错误提示2
function check_empty_field2(textfield, field, msg) {
	var obj = $("#"+field+"_msg");
	if(textfield.val() == "") {
		obj.html(msg+"不能为空");	
		obj.show();
		return true;
	} else {
		obj.html("");	
		obj.hide();
	}
	return false;
}
//=============================================================
